<?php

namespace app\advertisement\controller;

use app\common\controller\PCBase;
use app\BaseController;//测试专用
use app\advertisement\logic\AdvertisementLogic;
use think\facade\Db;
use Throwable;
use app\common\library\Upload;

class Advertisement extends PCBase
{


    public function initialize(): void
    {
        parent::initialize();
    }

    /**
     * index
     * @throws Throwable
     */
    public function index()
    {
        $params     = $this->request->post();
        $admin_id   = $this->getAdminId();
        $group_id   = $this->getAdminGroupId();
        $params['adminId']  = $admin_id;
        $params['group_id'] = $group_id;
        $AdvertisementLogic = new AdvertisementLogic();
        return $AdvertisementLogic->index($params);
    }

    /**
     * export
     * @throws Throwable
     */
    public function export()
    {
        $params     = $this->request->post();
        $AdvertisementLogic = new AdvertisementLogic();
        return $AdvertisementLogic->export($params);
    }

    /**
     * index
     * @throws Throwable
     */
    public function advinfo()
    {
        $params     = $this->request->post();
        $AdvertisementLogic = new AdvertisementLogic();
        return $AdvertisementLogic->advinfo($params);
    }

    /**
     * 添加
     * @throws Throwable
     */
    public function add()
    {
        $post = $this->request->post();
        $AdvertisementLogic = new AdvertisementLogic();
        $result = $AdvertisementLogic->add($post);
        return $result;
    }

    /**
     * 回显
     * @throws Throwable
     */
    public function find($id = null)
    {
        $post = $this->request->post();
        $id = $post['id'] ?? 0;
        $AdvertisementLogic = new AdvertisementLogic();
        $result = $AdvertisementLogic->find($id);
        return $result;
    }
    /**
     * 编辑
     * @throws Throwable
     */
    public function edit()
    {
        $post = $this->request->post();
        $AdvertisementLogic = new AdvertisementLogic();
        $result = $AdvertisementLogic->edit($post);
        return $result;
    }

    /**
     * 确认
     * @throws Throwable
     */
    public function confirm()
    {
        $post = $this->request->post();
        $AdvertisementLogic = new AdvertisementLogic();

        $group_id   = $this->getAdminGroupId();
        $post['group_id'] = $group_id;

        $result = $AdvertisementLogic->confirm($post);
        return $result;
    }

}
